package com.easemob.chatuidemo.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.easemob.chatuidemo.R;

public class updatePicActivity extends Activity implements OnClickListener {
    
    private ImageView iv_loadpic;
    private Button btn_uploadpic_take;
    private Button btn_uploadpic_pick;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_upload_pic);
        
        iv_loadpic = (ImageView) findViewById(R.id.iv_user_head);
        btn_uploadpic_take = (Button) findViewById(R.id.btn_uploadpic_take);
        btn_uploadpic_pick = (Button) findViewById(R.id.btn_uploadpic_pick);
        
        btn_uploadpic_take.setOnClickListener(this);
        btn_uploadpic_pick.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.btn_uploadpic_take:
            Intent takeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            //下面这句指定调用相机拍照后的照片存储的路径
//            takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, 
//                    Uri.fromFile(new File(Environment.getExternalStorageDirectory(), IMAGE_FILE_NAME)));
//            startActivityForResult(takeIntent, REQUESTCODE_TAKE);
            break;
        case R.id.btn_uploadpic_pick:

            break;

        default:
            break;
        }
        
    }
    
//    final CharSequence[] items = { "拍摄", "从相册选择" };
//    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//    builder.setTitle("请选择方式");
//    // items使用全局的finalCharSequenece数组声明
//    builder.setItems(items, new DialogInterface.OnClickListener() {
//        @Override
//        public void onClick(DialogInterface dialog, int which) {
//            // TODO Auto-generated method stub
//            String select_item = items[which].toString();
//            Toast.makeText(getActivity(), "选择了---》" + select_item,
//                    Toast.LENGTH_SHORT).show();
//
//            switch (which) {
//            case 0:
//                takePhoto();
//                break;
//            case 1:
//                pickPhoto();
//                break;
//
//            default:
//                break;
//            }
//        }
//    });
//    builder.show();
    
    

}
